package org.eimac.imacquizz;

import org.eimac.imacquizz.R;
import org.eimac.imacquizz.R.id;
import org.eimac.imacquizz.R.layout;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class EmailActivity extends Activity {

	private EditText text;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.email);

		findViewById(R.id.send).setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				send();
			}
		});

		text = (EditText) findViewById(R.id.text);
		
        Button boutonMenu = (Button) findViewById(R.id.menu);
        boutonMenu.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent intent = new Intent();
                setResult(RESULT_OK, intent);
                finish();
            }

        });
	}

	private void send() {
		Intent intent = new Intent(Intent.ACTION_SEND);

		intent.setType("message/rfc822");
		intent.putExtra(Intent.EXTRA_TEXT, text.getText().toString());
		intent.putExtra(Intent.EXTRA_SUBJECT, "Quizz IMAC - Contact");
		intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "sanaa.bk@gmail.com" });

		startActivity(Intent.createChooser(intent, "Envoyer un email"));
	}

}
